<template>
  <li class="CommodityCard" @click="ToDetail(item.id)">
    <van-image :src="item.image"></van-image>
    <div class="desc">
      <p class="name">{{ item.store_name }}</p>
      <span class="price">￥{{ item.price }}</span>
    </div>
  </li>
</template>

<script>
export default {
  props: ["item"],
  methods: {
    ToDetail(id) {
      if (id == this.$route.query.id) {
        return;
      }
      this.$router.push({
        path: "/detail",
        query: {
          id,
        },
      });
    },
  },
};
</script>

<style lang="less">
.CommodityCard {
  display: flex;
  flex-direction: column;
  align-items: center;
  border-radius: 8px;
  .van-image {
    width: 100%;
    height: 75%;
    border-radius: 6px;
    img {
      border-radius: 6px;
    }
  }
  .desc {
    width: 100%;
    margin-top: 5px;
    .name {
      width: 100%;
      font-size: 14px;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .price {
      font-weight: bold;
      color: red;
      font-size: 14px;
    }
  }
}
</style>